home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / dvglue10.arc / TVINT15I.C < prev    next >
C/C++ Source or Header  |  1988-08-13  |  2KB  |  74 lines

  1. /*=======================================================*/
  2. /*  TVINT15I.C                                           */
  3. /*     low-level functions for TV software interrupts    */
  4. /*     requires MASM or A86 to recompile                 */
  5. /*                                                       */
  6. /*  (c) Copyright 1988 Ralf Brown  All Rights Reserved   */
  7. /*  May be freely copied for noncommercial use, so long  */
  8. /*  as this copyright notice remains intact, and any     */
  9. /*  changes are marked in the comment blocks preceding   */
  10. /*  functions.                                           */
  11. /*=======================================================*/
  12.  
  13. #pragma inline
  14.  
  15. #include "tvapi.h"
  16.  
  17. /*======================================================*/
  18. /* _TVinterrupt_handler  low-level function which       */
  19. /*                       passes control to user         */
  20. /*                       interruption routine           */
  21. /*   Ralf Brown 4/8/88                                  */
  22. /*======================================================*/
  23.  
  24. void far pascal _TVinterrupt_handler(void)
  25. {
  26.    void far (*handler)(void) ;
  27.  
  28.    asm push es
  29.    asm push ds
  30.    asm push di
  31.    asm push si
  32.    asm push dx
  33.    asm push cx
  34.    asm push bx
  35.    asm push ax
  36. /* now that we've saved all the registers, call the real handler */
  37.    asm mov handler,di     /* build return address, and then jump to it */
  38.    asm mov handler+2,es
  39.    asm mov ax,DGROUP
  40.    asm mov ds,ax
  41.    (*handler)() ;
  42. /* restore the registers and return */
  43.    asm pop ax
  44.    asm pop bx
  45.    asm pop cx
  46.    asm pop dx
  47.    asm pop si
  48.    asm pop di
  49.    asm pop ds
  50.    asm pop es
  51. }
  52.  
  53. /*======================================================*/
  54. /* _restore_DS   get back TurboC's data segment         */
  55. /*   Ralf Brown 8/9/88                                  */
  56. /*======================================================*/
  57.  
  58. WORD _restore_DS(void)
  59. {
  60. #ifdef __TINY__
  61.    asm mov ax,cs
  62.    asm mov ds,ax
  63. #endif
  64. #if !defined(__HUGE__) && !defined(__TINY__)
  65.    asm mov ax,DGROUP
  66.    asm mov ds,ax
  67. #else
  68.    asm mov ax,ds   /* huge model sets DS on every function entry */
  69. #endif
  70.    return _AX ;
  71. }
  72.  
  73. /* End of TVINT15I.C */
  74.